From b03784eb979bb8c7fee317f1ddeeed67c35eb63e Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 17 May 2016 15:04:23 +0200 Subject: [PATCH] wayland: Add get_monitor_at_window to Wayland backend Given that Wayland has no global coordinate, the only way for gdk to retrieve the monitor a window last entered is to retrieve it from the GdkWaylandWindow itself. Implement the backend specific get_monitor_at_window() to return the monitor that was last entered by the window. https://bugzilla.gnome.org/show_bug.cgi?id=766566 --- gdk/wayland/gdkdisplay-wayland.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 7b54c7749d..c541a6a0b8 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -37,6 +37,7 @@ #include "gdkkeysprivate.h" #include "gdkprivate-wayland.h" #include "gdkglcontext-wayland.h" +#include "gdkwaylandmonitor.h" #include "pointer-gestures-unstable-v1-client-protocol.h" #include "tablet-unstable-v1-client-protocol.h" @@ -840,6 +841,31 @@ gdk_wayland_display_get_monitor (GdkDisplay *display, return (GdkMonitor *)display_wayland->monitors->pdata[monitor_num]; } +static GdkMonitor * +gdk_wayland_display_get_monitor_at_window (GdkDisplay *display, + GdkWindow *window) +{ + GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); + struct wl_output *output; + int i; + + g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL); + + output = gdk_wayland_window_get_wl_output (window); + if (output == NULL) + return NULL; + + for (i = 0; i < display_wayland->monitors->len; i++) + { + GdkMonitor *monitor = display_wayland->monitors->pdata[i]; + + if (gdk_wayland_monitor_get_wl_output (monitor) == output) + return monitor; + } + + return NULL; +} + static void gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) { @@ -894,6 +920,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class) display_class->get_n_monitors = gdk_wayland_display_get_n_monitors; display_class->get_monitor = gdk_wayland_display_get_monitor; + display_class->get_monitor_at_window = gdk_wayland_display_get_monitor_at_window; } static void -- 2.30.2